extends Area2D
## 分数
@export var value:int=10

@onready var game:Node2D = $'/root/World'
@onready var sprite:AnimatedSprite2D = $AnimatedSprite2D

func _ready():
	self.body_entered.connect(_on_body_entered)
	
func _process(delta):
	pass

func _on_body_entered(body):
		
	if body.is_in_group('player'):
		game.add_score(value)
		sprite.play('collected')
		sprite.animation_finished.connect(_on_animation_finished)

func _on_animation_finished():
	queue_free()
